package com.itheima.wemedia.feign;

import com.itheima.common.vo.ResultVo;
import com.itheima.wemedia.pojo.WmUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @version 1.0
 * @description spring创建feign客户端 接口，通过动态代理方法来创建feign，注册到spring容器
 *              默认是name的值（微服名称）, 如果有这个微服的多个feign客户端则会因id冲突报错
 *              contextId指定 这个创建的动态代理feign的id为多少，避免冲突
 *              指定spring容器中这个bean对象的id
 * @package com.itheima.wemedia.feign
 */
@FeignClient(name = "leadnews-wemedia",contextId = "wmUserFeign")
public interface WmUserFeign {

    //通过ap_user_id查询 wm_user表
    // apUserId=null /api/wmUser/getByApUserId/  404
    @GetMapping("/api/wmUser/getByApUserId/{apUserId}")
    ResultVo<WmUser> getByApUserId(@PathVariable(value = "apUserId") Long apUserId);

    /**
     * 通过appUserId查询自媒体账号信息
     * @param wmUser
     * @return
     */
    //创建WmUser对象
    @PostMapping("/api/wmUser/add")
    ResultVo<WmUser> addWmUser(@RequestBody WmUser wmUser);
}
